<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="/css/nav.css">
    <link rel="stylesheet" type="text/css" href="/font/iconfont.css">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="/js/nav.js"></script>
</head>
<body>
<div th:include="/common/nav :: nav" class="nav" style="float: left;"></div>
<div style="float: left;height: 100%;width: 87.5%;background-color: rgb(235, 243, 243);" >
    <div class="content">

        <form class="layui-form" action="">
            <div class="layui-form-item" style="font-size:30px;text-align: center;font-weight: bolder">添加快递员：</div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名<span class="red">*</span></label>
                <div class="layui-input-inline">
                    <input type="text" name="realName" id="realName" required  lay-verify="required" placeholder="请输入快递员姓名" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux ">辅助文字</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号<span class="red">*</span></label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" id="phone" required  lay-verify="required" placeholder="请输入快递员手机号" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">登录名称<span class="red">*</span></label>
                <div class="layui-input-inline">
                    <input type="text" name="username" required id="login-name"  lay-verify="required" placeholder="请输入快递员登录名称" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">辅助文字</div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">登录密码<span class="red">*</span></label>
                <div class="layui-input-inline">
                    <input type="password" name="password" id="password" required lay-verify="required" placeholder="请输入快递员登录密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"></div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">家庭住址<span class="red">*</span></label>
                <div class="layui-input-block">
                    <textarea name="address" id="address" placeholder="请输入内容" required lay-verify="required" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别<span class="red">*</span></label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="男" title="男" checked>
                    <input type="radio" name="sex" value="女" title="女" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工作区域<span class="red">*</span></label>
                <div class="layui-input-block">
                    <select name="workingAreaId" lay-verify="required" >

                        <option th:each="item : ${workingAreas}" th:value="${item.getId()}" th:text="${item.getAddressName()}"></option>
                    </select>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

        <script>
            //Demo
            layui.use('form', function(){
                var form = layui.form;

                //监听提交
                form.on('submit(formDemo)', function(data){


                    //layer.msg("d:"+$("#realName").val()+JSON.stringify(data.field));
                    //        {"realName":"cailong ","phone":"1343434","username":"123","password":"456","address":"华软","sex":"男","workingAreaId":"2"}
                    $.post("/admin/addCourier",{
                        "name":$("#realName").val(),
                        "phone":$("#phone").val(),
                        "username":$("#login-name").val(),
                        "password":$("#password").val(),
                        "address":$("#address").val(),
                        "workingAreaId":$(':input[name=workingAreaId]').val(),
                        "sex":$(':radio[name=sex]:checked').val()
                    },function (data) {

                        if (data.code ==200){
                            layer.alert(data.msg,{icon:6});
                        }else{
                            layer.alert(data.msg,{icon:5});
                        }


                    })


                    return false;
                });
            });
        </script>
    </div>
</div>
</body>
</html>
